<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>我的购物车</title>
		<link rel="stylesheet" href="../css/reset.css" />
		<link rel="stylesheet" href="../css/base.css" />
		<script type="text/javascript" src="../js/jquery-1.12.0.js" ></script>
		<script src="../js/mycookie.js"> </script>
		<script type="text/javascript" src="../js/js.js" ></script>
	</head>
	<body>
		<!--页面顶部-->
		<div class="Stop">
			<div class="shpTop">
				<p><a href="landing.html" >请登录</a>|<a href="register.html" >免费注册</a></p>
				
			</div>
		</div>
		
		<!--页头部-->
		<div class="subHeader w985">
			<h1 class="subLogo left"><a href="#"><img src="../css/img/sublogo2.jpg" width="210" height="99" ></a></h1>
			<ul class="ordersLocation left">
				<li>我的购物车</li>
				<li>填写核对订单信息</li>
				<li>提交并付款</li>
				<li>收货确认</li>
				<li>评价</li>
			</ul>
		</div>
		
		<!--二级页主体-->
	<div class="subMain w985">
		<div class="shoppingNav">
			<ul class="wrap bg1">
				<li class="hover">我的购物车</li>
				<li>订单信息</li>
				<li>提交并付款</li>
			</ul>
		</div>
		<div class="myCart">
		<table class="myCartNum1" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
					<td width="357">商品名</td>
					<td width="145">单价（元）</td>
					<td width="112">单位</td>
					<td width="123">数量</td>
					<td width="158">总价（元）</td>
					<td width="83">操作</td>
				</tr>
		</tbody>
		</table>
		<table class="myCartNum2" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
				  <td colspan="6"><span></span></td>
			    </tr>
		</tbody>
		</table>
		
		<form>
		<table bgcolor="#e0e0e0" class="myCartNum3" cellpadding="0" cellspacing="1">
				   
			<tbody id="adds">
				<!--
                	从cookie中把商品详情页的商品信息加载进来
                -->
			    
			    
			    
			    
			
							
				<tr align="right" bgcolor="#f5f5f5" height="148">
					<td colspan="6">
						<p class="zongjitext jians nums">商品数量总计：<b id="jianshu">0件</b></p>
						<p class="zongjitext">商品金额总计：<b class="zongjia zhongshu">￥0.00元</b></p>
						<input type="hidden" id="zongjia" name="" value="1275">
					</td>
				</tr>
		</tbody>
		</table>
	
		<table bgcolor="#e0e0e0" class="myCartNum4" cellpadding="0" cellspacing="0">
			<tbody>
			<tr bgcolor="#f5f5f5" align="right" height="36" class="jiesuan">
				<td colspan="5">
					<input class="btn" type="submit" value="">
						<strong class="zongjia zhongshu " >0元</strong>
						<span>商品总价（不含运费）：</span>
						<div class="goto">
						   <a href="#">继续购物</a>
						</div>
				</td>
			</tr>
		</tbody>
		</table>
		</form>
	 </div>
		
	</div>
	
	
	  <!--注册页面底部-->
        <div class="end sub">
			<div class="serviceLink">
				<dl>
					<dt>购物指南</dt>
								   <dd><a href="#">注册新用户</a></dd>
					 			   <dd><a href="#">购物流程</a></dd>
					 			   <dd><a href="#">订单查询</a></dd>
					 			   <dd><a href="#">常见购物问题</a></dd>
					 			
				</dl>
				<dl>
					<dt>订单支付</dt>
							       <dd><a href="#">货到付款</a></dd>
					 			   <dd><a href="#">在线支付</a></dd>
					 			   <dd><a href="#">如何办理退款</a></dd>
					 			   <dd><a href="#">发票制度</a></dd>
					 			
				</dl>
				<dl>
					<dt>订单配送</dt>
								   <dd><a href="#">配送费用</a></dd>
					 			   <dd><a href="#">配送时间和范围</a></dd>
					 			   <dd><a href="#">配送常见问题</a></dd>
					 			   <dd><a href="#">配送方式</a></dd>
					 			
				</dl>
				<dl>
					<dt>售后服务</dt>
							       <dd><a href="#">缺货处理</a></dd>
					 			   <dd><a href="#">退换货政策</a></dd>
					 			   <dd><a href="#">退换货流程</a></dd>
					 			   <dd><a href="#">联系客服</a></dd>
					 			
				</dl>
				<dl>
					<dt>帮助中心</dt>
								   <dd><a href="#">关于我们</a></dd>
					 			   <dd><a href="#">积分兑换</a></dd>
					 			   <dd><a href="#">建议反馈</a></dd>
					 			   <dd><a href="#">正品保证</a></dd>
				</dl>	 		
			</div>
			
			
			<p class="logo">Copyright © 2016 北京中一文仪商贸有限公司 All Rights Reserved 备案号：京ICP备14012128号&nbsp;&nbsp;<img src="../css/img/pic.gif"> </p>
		</div>

	<script>
	var zongji=0;
	var str = getCookie("arr");	
	var arr =JSON.parse(str);
	console.log(arr);
    $(function(){
     
			
		    $jianshu=$('#jianshu')
		   
		    for (var i=0;i<arr.length;i++) {
		    	var moy =arr[i].price;	
				var prices = (moy.replace(/[^0-9,\.]+/ig,""));//获取出价格，存储在变量
				
		    	$tr = $('<tr bgcolor="#ffffff" height="73"></tr>');
			    $td1=$('<td width="357" valign="top"></td>');
			         $('<a class="img" href="#"><img src="'+arr[i].osimg+'" style="width:50px; height:50px"></a>').appendTo($td1);
		             $('<a class="name" href="#">'+arr[i].name+'</a>').appendTo($td1);
		             $('<span class="col">颜色：默认</span>').appendTo($td1);		
		        $td1.appendTo($tr );        	
	            $('<td width="145">￥'+prices+'元</td><td width="112">台</td>').appendTo($tr ); 
				$('<td width="123" class="over"><input type="hidden" name="dingdanghao" value="0"><span class="jia gw_jian" >-</span><input readonly="readonly" style="width:40px" value="1" class="text_box1" type="text"><span class="jian gw_jia" >+</span><input type="hidden" name="g_id" value="7851"></td>').appendTo($tr)
				$('<td width="158" color="#df1800" class="xiaoji">￥<span>'+prices+'</span>元</td>').appendTo($tr)
				$('<td width="83"><a class="shoucangshanchu" href="#" >收藏</a><a class="shoucangshanchu" href="#">删除</a><input type="hidden" name="goodsid" id="goodsid" value="7851"><input type="hidden" name="molds" id="molds" value="4"></td>').appendTo($tr);
		  		$jianshu.html(parseInt(arr[i].unmber))
				$('form #adds').prepend($tr);				
				
		    	
		    }
		
			
		         			
			//商品计算价格
			
			//加法
			$(".gw_jia").click(function (zongji) {
				var t = $(this).parents().children('.text_box1');
				var $xiaoji =$(this).parents().children('.xiaoji').children('span');
				$jianshu.html( parseInt($jianshu.html())+1);
			    $xiaoji.html( (parseInt($xiaoji.html())+parseInt(prices)).toFixed(2));
				t.val(parseInt(t.val()) + 1);				
				setTotal();
				
			})
			
			//减法
			$(".gw_jian").click(function (zongji) {
				var t = $(this).parents().children('.text_box1');
				var $xiaoji =$(this).parents().children('.xiaoji').children('span');
				$jianshu.html( parseInt($jianshu.html())-1);
				$xiaoji.html( (parseInt($xiaoji.html())-parseInt(prices)).toFixed(2));
				t.val(parseInt(t.val()) - 1)
				setTotal(); 
			})
			function setTotal() {
	          
	       
				$(".zhongshu ").html((( parseInt($jianshu.html()))*prices).toFixed(2));
				$("#jianshu").html((parseInt($jianshu.html()))) ;
				
			}
			setTotal();
			
			//删除时候模块
		 	console.log(zongji);			 
	        $(".shoucangshanchu").click(function () { 
	       
	        var shangcu =  $(this).parent().parent().children('.over').children('.text_box1').val();
	        console.log(shangcu);
	        $jianshu.html(parseInt( $jianshu.html())-parseInt(shangcu))    
	        setTotal();
	        $(this).parent().parent().remove();
	        })
		         
     	
     		
	 })
		
		
		
	</script>



	
	
	
	</body>
</html>
